//
//  DYRegistLoginViewController.m
//  BaiSi
//
//  Created by mac on 16/10/18.
//  Copyright © 2016年 DeYi. All rights reserved.
//

#import "DYRegistLoginViewController.h"
#import "DYLoginRegisterView.h"
#import "DYFastLoginView.h"


@interface DYRegistLoginViewController ()
@property (weak, nonatomic) IBOutlet UIView *topView;
@property (weak, nonatomic) IBOutlet UIView *middleView;
@property (weak, nonatomic) IBOutlet UIView *BottomView;
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *leftConstraint;

@end

@implementation DYRegistLoginViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    
    //设置顶部视图
    DYLoginRegisterView *loginView = [DYLoginRegisterView loginViewFromXib];
    [_middleView addSubview:loginView];
    
    //注册视图
    DYLoginRegisterView *registerView = [DYLoginRegisterView registerViewFromXib];
    registerView.xmg_x = _middleView.xmg_width * 0.5;
    [_middleView addSubview:registerView];
    
    //登录视图
    UIView *logView = _middleView.subviews[0];
    //    id view3 = logView.subviews[2];
    if ([logView.subviews[2] isKindOfClass:[UIButton class]]) {
        UIButton *view3 = logView.subviews[2];
        [view3 addTarget:self action:@selector(forgetPassword) forControlEvents:UIControlEventTouchUpInside];
    }
    
    //快速登录视图
    DYFastLoginView *fastView = [DYFastLoginView fastViewFromXib];
    [_BottomView addSubview:fastView];
    
    
}

#pragma mark - 状态栏显示样式(颜色)
- (UIStatusBarStyle)preferredStatusBarStyle {
    return UIStatusBarStyleLightContent;
}


#pragma mark - 点击事件处理
- (IBAction)ExitButtonClick:(id)sender {
    
    [self dismissViewControllerAnimated:YES completion:nil];
}

- (IBAction)RegistLoginButtonClick:(UIButton *)sender {
    
    sender.selected = !sender.selected;
    _leftConstraint.constant = _leftConstraint.constant == 0 ? -DYScreenW : 0;
    [UIView animateWithDuration:0.25 animations:^{
        [self.view layoutIfNeeded];
    }];

}

- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event {
    [self.view endEditing:YES];
}



- (void)forgetPassword {
    LHLog(@"忘记密码");
    //    UIViewController *vc = [[UIViewController alloc] init];
    //    vc.view.backgroundColor = [UIColor redColor];
    //    [self presentViewController:vc animated:YES completion:nil];
}

#pragma mark - 布局子控件
- (void)viewDidLayoutSubviews {
    [super viewDidLayoutSubviews];
    //登录视图
    UIView *logView = _middleView.subviews[0];
    logView.frame = CGRectMake(0, 0, _middleView.xmg_width * 0.5, _middleView.xmg_height);
    //注册视图
    UIView *registerView = _middleView.subviews[1];
    registerView.frame = CGRectMake(_middleView.xmg_width * 0.5, 0, _middleView.xmg_width * 0.5, _middleView.xmg_height);
    //快速登录视图
    UIView *fastView = _BottomView.subviews[0];
    fastView.frame = CGRectMake(0, 0, _BottomView.xmg_width, _BottomView.xmg_height);
    
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
